package dataPool;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by Administrator on 2018/6/14.
 */
public class MyPoolTest {
    private static void queryMysql(){
        MyPoolImpl myPool = PoolManager.getInstance();
        PoolConnnection poolConnnection = myPool.getConnection();
        ResultSet rs = poolConnnection.queryBysql("SELECT * FROM T_USER");
        System.out.println(Thread.currentThread().getName());
        try {
            while (rs.next()){
                System.out.print(rs.getString("ID"));
                System.out.print(rs.getString("NAME"));
                System.out.print(rs.getString("AGE"));

            }
            rs.close();
            poolConnnection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        for (int i =0;i <500;i++) {
           new Thread(new Runnable() {
               @Override
               public void run() {
                   queryMysql();
               }
           }).start();
       }
        System.out.println("耗时一共为："+(System.currentTimeMillis()-start)+"ms");
    }
}
